import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-11-09
 * Time: 17:14
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String str1 = scanner.next();
        String str2 = scanner.next();

        System.out.println(getMaxLength(str1,str2));
    }

    private static int getMaxLength(String str1, String str2) {
        int m = str1.length();
        int n = str2.length();

        int[][] dp = new int[m+1][n+1];
        int maxLength = 0;
        for(int i = 1; i < str1.length(); ++i) {
            for(int j = 1; j < str2.length(); ++j) {
                if(str1.charAt(i-1) == str2.charAt(j - 1)) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                    if(dp[i][j] > maxLength)
                        maxLength = dp[i][j];
                }
            }
        }
        return maxLength;
    }
}
